package codeforces.contest1731;

import java.util.Scanner;

@SuppressWarnings("DuplicatedCode")
public class ProblemF {
    private static final int p = 998244353;


    public static void main(String[] args) {
//        writeCoefficients();
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        System.out.println(solve(n, k));
    }


    private static long solve(int n, int k) {
        if (n == 1 || k < 2) return 0;
        long ans = 0;
        long[] coeff = COEFFICIENTS[n - 2];
        int m = coeff.length;
        long tmp = k;
        for (long c : coeff) {
            ans = (ans + c * tmp) % p;
            tmp = tmp * k % p;
        }
        return ans;
    }

    private static final int MAX_N = 50;
    private static final int MIN_K = 2;

    private static final long[][] COEFFICIENTS = {
            {831870294, 0, 166374059,},
            {831870294, 665496235, 166374059, 332748118,},
            {831870294, 665496235, 665496235, 332748118, 499122177,},
            {831870294, 665496235, 665496235, 665496235, 499122177, 665496236,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496236, 831870295,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 831870295, 1,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 1, 166374060,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 166374060, 332748119,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 332748119, 499122178,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 499122178, 665496237,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496237, 831870296,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 831870296, 2,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 2, 166374061,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 166374061, 332748120,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 332748120, 499122179,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 499122179, 665496238,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496238, 831870297,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 831870297, 3,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 3, 166374062,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 166374062, 332748121,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 332748121, 499122180,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 499122180, 665496239,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496239, 831870298,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 831870298, 4,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 4, 166374063,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 166374063, 332748122,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 332748122, 499122181,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 499122181, 665496240,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496240, 831870299,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 831870299, 5,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 5, 166374064,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 166374064, 332748123,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 332748123, 499122182,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 499122182, 665496241,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496241, 831870300,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 831870300, 6,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 6, 166374065,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 166374065, 332748124,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 332748124, 499122183,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 499122183, 665496242,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496242, 831870301,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 831870301, 7,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 7, 166374066,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 166374066, 332748125,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 332748125, 499122184,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 499122184, 665496243,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496243, 831870302,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 831870302, 8,},
            {831870294, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 665496235, 8, 166374067,}
    };


    private static int[] solveForSmall(int n) {
        //we need get values for n+3
        int[][] binomials = new int[n + 1][n + 1];
        for (int i = 0; i <= n; i++) {
            binomials[i][0] = 1;
            binomials[0][i] = 1;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                binomials[i][j] = binomials[i - 1][j] + binomials[i][j - 1];
                if (binomials[i][j] >= p) binomials[i][j] -= p;
            }
        }

        int[] ans = new int[n + 2];
        for (int k = MIN_K, j = 0; j < ans.length; k++, j++) {
            long tmp = 0;
            for (int i = 1; i < n; i++) {
                for (int x = 0; x <= i - 1; x++) {
                    for (int y = x + 1; y <= n - i; y++) {
                        long tmp2 = (long) binomials[x][i - 1 - x] * binomials[y][n - i - y] % p;
                        for (int t = 1; t < k; t++) {
                            tmp += (long) t * tmp2 % p *
                                    powMod(t - 1, x) % p * powMod(k - t, y) % p *
                                    powMod(k - t + 1, i - 1 - x) % p * powMod(t, n - i - y) % p;
                            if (tmp >= p) tmp -= p;
                        }
                    }
                }
            }
            ans[k - MIN_K] = (int) tmp;
        }
        return ans;
    }

    private static int powMod(int a, int b) {
        long res = 1;
        while (b != 0)
            if ((b & 1) != 0) {
                res = (res * a) % p;
                --b;
            } else {
                a = (int) (((long) a * a) % p);
                b >>= 1;
            }
        return (int) res;
    }

    public static int reverse(int a) {
        int t = 0, newT = 1, r = p, newR = a, q, tmp;
        while (newR != 0) {
            q = r / newR;
            tmp = t - q * newT;
            t = newT;
            newT = tmp;
            tmp = r - q * newR;
            r = newR;
            newR = tmp;
        }
        if (r > 1) return -1;
        if (t < 0) t += p;
        return t;
    }

    private static void writeCoefficients() {
        StringBuilder sb = new StringBuilder();
        sb.append("private static final long[][] COEFFICIENTS = {\n");
        for (int n = 2; n <= MAX_N; n++) {
            int[] y = solveForSmall(n);
            int m = y.length;
            int[][] x = new int[m][m];
            for (int i = 0, k = MIN_K; i < m; i++, k++) {
                x[i][0] = 1;
                for (int j = 1; j < m; j++) {
                    x[i][j] = (int) ((long) x[i][j - 1] * k % p);
                }
            }
            int[] coeffs = solveMatrix(x, y);
            sb.append("{");
            for (int i = 1; i < m; i++) sb.append(coeffs[i]).append(",");
            sb.append("},\n");
        }
        System.out.println(sb);
    }

    private static int[] solveMatrix(int[][] x, int[] y) {
        int n = x.length;
        for (int i = 0; i < n; i++) {
            int tmpI = i;
            while (tmpI < n && x[tmpI][i] == 0) tmpI++;
            int[] tmpArr = x[i];
            x[i] = x[tmpI];
            x[tmpI] = tmpArr;
            int tmp = y[i];
            y[i] = y[tmpI];
            y[tmpI] = tmp;

            long reversed = reverse(x[i][i]);
            for (int j = i; j < n; j++) x[i][j] = (int) (x[i][j] * reversed % p);
            y[i] = (int) (y[i] * reversed % p);
            for (int k = i + 1; k < n; k++) {
                long multiplier = x[k][i];
                for (int j = i; j < n; j++) {
                    x[k][j] = (int) ((x[k][j] - x[i][j] * multiplier) % p);
                    if (x[k][j] < 0) x[k][j] += p;
                }
                y[k] = (int) ((y[k] - y[i] * multiplier) % p);
                if (y[k] < 0) y[k] += p;
            }
        }
        for (int i = n - 1; i > 0; i--) {
            for (int k = i - 1; k >= 0; k--) {
                long multiplier = x[k][i];
                x[k][i] = 0;
                y[k] = (int) ((y[k] - y[i] * multiplier) % p);
                if (y[k] < 0) y[k] += p;
            }
        }
        return y;
    }
}
